package com.ruoyi.project.zxcrm.controller;


import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.zxcrm.mapper.CrmSmsSendLogMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * 信息日志Controller
 *
 * @author mn
 * @date 2023-02-23
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/crm/smsLog")
public class CrmSmsLogController extends BaseController {

    private final CrmSmsSendLogMapper crmSmsSendLogMapper;

    @PreAuthorize("@ss.hasPermi('crm:smsMes:query')")
    @GetMapping("/sum")
    public AjaxResult queryLogSum() {
        return AjaxResult.success(crmSmsSendLogMapper.selectLogSum());
    }

    @GetMapping("/unset")
    public AjaxResult queryLogUnSetSum() {
        return AjaxResult.success(crmSmsSendLogMapper.selectLogUnsetSum());
    }

    @GetMapping("/TodaySum")
    public AjaxResult queryLogToDaySum() {
        return AjaxResult.success(crmSmsSendLogMapper.SelectToDay());
    }

    @GetMapping("/Today/Succeed")
    public AjaxResult queryLogToDaySucceedSum() {
        return AjaxResult.success(crmSmsSendLogMapper.SelectToDaySucceed());
    }

    @GetMapping("/UserStatistic")
    public AjaxResult SmsLogUserStatistic() {
        ArrayList<Integer> data = new ArrayList<>();
        int SmsUserSum = crmSmsSendLogMapper.selectLogSum();
        data.add(SmsUserSum);
        data.add(crmSmsSendLogMapper.selectLogUnsetSum());
        data.add(crmSmsSendLogMapper.SelectToDay());
        data.add(crmSmsSendLogMapper.SelectToDaySucceed());
        return AjaxResult.success(data);
    }
}
